function t(t, e, i) {
    return e in t ? Object.defineProperty(t, e, {
        value: i,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = i, t;
}

var e = require("../../33BC8B13A71FB5DF55DAE314211CA4D1.js");

getApp();

Component({
    properties: {
        boxWidth: {
            type: Number
        },
        boxHeight: {
            type: Number
        },
        width: {
            type: Number
        },
        height: {
            type: Number
        },
        left: {
            type: Number
        },
        top: {
            type: Number
        },
        _id: {
            type: String,
            required: !0
        }
    },
    data: {
        imgList: [],
        initId: 0,
        selectedId: null,
        idx: null,
        touchData: null,
        isShow: !1,
        eventType: 1,
        pointType: null,
        touchIdx: 0,
        recordList: [],
        recordIdx: -1,
        isShowTip: !1
    },
    lifetimes: {
        ready: function() {
            this.ctx = wx.createCanvasContext(this.data._id, this);
        }
    },
    methods: {
        addImg: function(i) {
            var a = this, s = i.img, r = this.data.width, n = this.data.height, h = r / s.width, o = n / s.height, d = h > o ? o : h;
            s.scale = d, s.y = 0, s.x = (r - s.width * d) / 2, s.degree = 0;
            var l = this.data.initId + 1;
            this.setData({
                initId: l
            });
            var g = {};
            if ("online" === i.type) {
                var c = this.getImgSource(s.path);
                if (c) {
                    (g = this.getImgData(c.source)).id = l, g.path = c.path, g.selected = !0, g.decals = JSON.parse(JSON.stringify(s.decals));
                    var u = this.data.imgList.map(function(t) {
                        return t.selected = !1, t;
                    });
                    u.push(this.getImgPosition(g));
                    var x = u.length;
                    this.setData({
                        imgList: u,
                        idx: x - 1
                    }, function() {
                        a.filterRecordList({
                            type: 1,
                            hold: !0
                        }), a.draw(), a.triggerEvent("updatePrice"), a.triggerEvent("getDrewIdx", {
                            idx: x - 1,
                            len: x,
                            path: g.path,
                            type: s.type,
                            imgType: "online"
                        });
                    });
                } else wx.showLoading({
                    title: "加载图片中...",
                    mask: !0
                }), e(s.path).then(function(t) {
                    wx.hideLoading(), (g = a.getImgData(s)).id = l, g.path = t.path, g.selected = !0;
                    var e = a.data.imgList.map(function(t) {
                        return t.selected = !1, t;
                    });
                    e.push(a.getImgPosition(g));
                    var r = e.length;
                    a.setData({
                        imgList: e,
                        idx: r - 1
                    }, function() {
                        a.filterRecordList({
                            type: 1,
                            hold: !0
                        }), a.draw(), a.triggerEvent("updatePrice"), a.triggerEvent("getDrewIdx", {
                            idx: r - 1,
                            len: r,
                            path: g.path,
                            type: s.type,
                            imgType: i.type
                        });
                    });
                }).catch(function() {
                    wx.hideLoading();
                });
            } else {
                (g = this.getImgData(s)).id = l, g.path = s.path, g.selected = !0;
                var p = this.data.imgList.map(function(t) {
                    return t.selected = !1, t;
                });
                p.push(this.getImgPosition(g));
                var y = p.length;
                this.setData({
                    imgList: p,
                    idx: y - 1
                }, function() {
                    var e;
                    "text" !== s.type && a.filterRecordList({
                        type: 1
                    }), a.draw(), a.triggerEvent("getDrewIdx", (e = {
                        idx: y - 1,
                        len: y
                    }, t(e, "len", y), t(e, "path", g.path), t(e, "type", s.type), t(e, "imgType", i.type), 
                    t(e, "active", "text" === s.type), e));
                });
            }
        },
        filterRecordList: function(t) {
            var e = this, i = t.type, a = JSON.parse(JSON.stringify(this.data.imgList)), s = this.data.recordList, r = s.length, n = this.data.recordIdx, h = {};
            if (1 === i) s = s.slice(0, n + 1), t.update ? s[n] = a : (s.push(a), 10 === r && s.splice(1, 11)), 
            h.recordList = JSON.parse(JSON.stringify(s)), h.recordIdx = s.length - 1; else if (2 === i) {
                if (!r || -1 === n) return;
                h.recordIdx = n - 1;
            } else if (3 === i) {
                if (!r || n === r - 1) return;
                h.recordIdx = n + 1;
            }
            var o = null;
            if (h.imgList = 1 !== i ? h.recordIdx > -1 ? JSON.parse(JSON.stringify(s[h.recordIdx])) : [] : a, 
            h.imgList.length) for (var d = 0; d < h.imgList.length; d++) if (h.imgList[d].selected) {
                o = d;
                break;
            }
            h.idx = o, this.setData(h, function() {
                if (e.triggerEvent("updatePrice"), e.triggerEvent("getRecordData", {
                    len: s.length,
                    idx: h.recordIdx
                }), !t.hold) if (1 !== i && e.draw(), null !== o && h.imgList[o]) {
                    var a = h.imgList[o];
                    e.triggerEvent("getDrewIdx", {
                        idx: o,
                        type: a.type,
                        len: h.imgList.length,
                        path: a.path,
                        imgType: "local"
                    });
                } else e.triggerEvent("getDrewIdx", {
                    idx: null
                });
            });
        },
        getImgData: function(t) {
            var e = JSON.parse(JSON.stringify(t));
            return {
                source: e,
                width: e.width,
                height: e.height,
                decals: e.decals ? JSON.parse(JSON.stringify(e.decals)) : null,
                x: e.x,
                y: e.y,
                scale: e.scale,
                color: e.color || "",
                fontSize: e.fontSize || 80,
                isBold: e.isBold || !1,
                degree: 0,
                selected: !1,
                type: e.type || "img",
                mirror: !1
            };
        },
        getImgSource: function(t) {
            var e = this.data.imgList, i = null, a = !0, s = !1, r = void 0;
            try {
                for (var n, h = e[Symbol.iterator](); !(a = (n = h.next()).done); a = !0) {
                    var o = n.value;
                    if (o.source.path === t) {
                        i = {
                            source: o.source,
                            path: o.path
                        };
                        break;
                    }
                }
            } catch (t) {
                s = !0, r = t;
            } finally {
                try {
                    !a && h.return && h.return();
                } finally {
                    if (s) throw r;
                }
            }
            return i;
        },
        unselectAll: function() {
            var t = this, e = this.data.imgList.map(function(t) {
                return t.selected = !1, t;
            });
            this.setData({
                imgList: e,
                idx: null
            }, function() {
                t.triggerEvent("getDrewIdx", {
                    idx: null
                }), t.draw();
            });
        },
        getDiyData: function() {
            return {
                imgList: this.data.imgList
            };
        },
        handleType: function(t) {
            var e = this, i = JSON.parse(JSON.stringify(this.data.imgList)), a = i.length;
            if (!(a < 1)) {
                var s = this.data.idx, r = i[s];
                if (1 === t) {
                    if (s === a - 1) return void wx.showToast({
                        title: "已经是最顶层了",
                        icon: "none"
                    });
                    var n = i[s + 1];
                    i[s] = n, i[s + 1] = r, this.setData({
                        idx: s + 1
                    }, function() {
                        e.triggerEvent("getDrewIdx", {
                            idx: s + 1,
                            len: i.length,
                            path: i[s + 1].path,
                            type: r.type,
                            imgType: "local"
                        });
                    });
                } else if (2 === t) {
                    if (0 === s) return void wx.showToast({
                        title: "已经是最底层了",
                        icon: "none"
                    });
                    var h = i[s - 1];
                    i[s] = h, i[s - 1] = r, this.setData({
                        idx: s - 1
                    }, function() {
                        e.triggerEvent("getDrewIdx", {
                            idx: s - 1,
                            len: i.length,
                            path: r.path,
                            type: r.type,
                            imgType: "local"
                        });
                    });
                } else if (3 === t) {
                    var o = r.degree % 360, d = o = o >= 0 ? o : 360 + o;
                    o >= 0 && o < 45 || o >= 315 && o < 360 ? d = 0 : o >= 45 && o < 135 ? d = 90 : o >= 135 && o < 225 ? d = 180 : o >= 225 && o < 315 && (d = 270), 
                    r.degree = d, i[s] = this.getImgPosition(r);
                } else if (4 === t) {
                    var l = this.data.width;
                    r.x = Math.floor((l - r.scale * r.width) / 2), i[s] = this.getImgPosition(r);
                }
                this.setData({
                    imgList: i
                }, function() {
                    e.filterRecordList({
                        type: 1,
                        update: !0
                    }), e.draw();
                });
            }
        },
        handleText: function(t, e, i) {
            var a = this, s = this.data, r = s.idx, n = s.imgList;
            "number" == typeof r && "text" === n[r].type ? "" === t ? (n.splice(r, 1), this.setData({
                idx: null,
                imgList: n
            }, function() {
                a.triggerEvent("getDrewIdx", {
                    idx: null,
                    type: "text",
                    active: !0
                }), a.draw();
            })) : (n[r].path = t, n[r].color = e, n[r].isBold = i, this.setData({
                imgList: n
            }, function() {
                a.triggerEvent("getDrewIdx", {
                    idx: r,
                    type: "text",
                    len: n.length,
                    path: n[r].path,
                    imgType: "local",
                    active: !0
                }), a.draw();
            })) : t ? this.addImg({
                type: "local",
                img: {
                    width: this.data.width,
                    height: 100,
                    path: t,
                    type: "text",
                    color: e,
                    isBold: i
                }
            }) : this.setData({
                idx: null
            }, function() {
                a.triggerEvent("getDrewIdx", {
                    idx: null,
                    type: "text",
                    active: !0
                });
            });
        },
        onTouch: function(e) {
            var i = this, a = e.type, s = this.data.touchData, r = this.data.imgList, n = e.touches, h = this.data.eventType, o = this.data.idx, d = this.data.touchIdx, l = this.data.pointType;
            if (r.length) switch (a) {
              case "touchend":
              case "touchstart":
                var g = n.length;
                if (!g) {
                    if (null !== o) {
                        var c = r[o], u = !1, x = !0, p = !1, y = void 0;
                        try {
                            for (var f, v = c.position[Symbol.iterator](); !(x = (f = v.next()).done); x = !0) {
                                var m = f.value;
                                if ((m.x < 0 || m.x > this.data.width || m.y < 0 || m.y > this.data.height) && "break" === function() {
                                    var t = !i.data.isShowTip;
                                    return u = !0, i.setData({
                                        isShowTip: !0
                                    }, function() {
                                        t && (i.triggerEvent("showTip", {
                                            isShow: !0
                                        }), setTimeout(function() {
                                            i.triggerEvent("showTip", {
                                                isShow: !1
                                            });
                                        }, 5e3));
                                    }), "break";
                                }()) break;
                            }
                        } catch (t) {
                            p = !0, y = t;
                        } finally {
                            try {
                                !x && v.return && v.return();
                            } finally {
                                if (p) throw y;
                            }
                        }
                        u || this.setData({
                            isShowTip: !1
                        });
                    }
                    return void this.setData({
                        isShow: !1
                    }, function() {
                        i.draw(), r.length && null !== o && i.filterRecordList({
                            type: 1
                        });
                    });
                }
                var w = this.getSelectedItem(n, r);
                if (null !== w.type) {
                    var I = w.type, D = {};
                    if (0 === I) r.splice(w.idx, 1), D = {
                        pointType: null,
                        idx: null,
                        touchIdx: null,
                        touchData: [],
                        eventType: 1,
                        imgList: r
                    }; else if (3 === I) {
                        var L;
                        r[w.idx].selected = !1;
                        var S = JSON.parse(JSON.stringify(r[w.idx]));
                        S.x = S.x - 10, S.y = S.y + 10, (S = this.getImgPosition(S)).selected = !0, r.push(S), 
                        w.idx = r.length - 1, t(L = {
                            pointType: null,
                            idx: w.idx,
                            touchIdx: null,
                            touchData: [],
                            eventType: 1
                        }, "idx", r.length - 1), t(L, "imgList", r), D = L;
                    } else 1 !== I && 2 !== I || (D = {
                        pointType: I,
                        eventType: 2,
                        touchData: n,
                        touchIdx: w.res[0] ? 0 : 1
                    });
                    this.setData(D, function() {
                        i.draw(), 0 !== I && 3 !== I || i.filterRecordList({
                            type: 1
                        }), 0 === I ? i.triggerEvent("getDrewIdx", {
                            idx: null
                        }) : i.triggerEvent("getDrewIdx", {
                            idx: w.idx,
                            len: r.length,
                            path: r[w.idx].path,
                            type: r[w.idx].type,
                            imgType: "local",
                            active: o === w.idx && "text" === r[w.idx].type
                        });
                    });
                } else if (null !== w.idx) if (1 === g) this.setData({
                    imgList: w.imgList,
                    eventType: 2,
                    idx: w.idx,
                    touchIdx: 0,
                    touchData: n,
                    isShow: !0,
                    pointType: null
                }, function() {
                    i.triggerEvent("getDrewIdx", {
                        idx: w.idx,
                        len: r.length,
                        path: r[w.idx].path,
                        type: r[w.idx].type,
                        imgType: "local",
                        active: o === w.idx && "text" === r[w.idx].type
                    }), i.draw();
                }); else {
                    var T = w.res, P = {
                        imgList: w.imgList,
                        idx: w.idx,
                        touchData: n,
                        isShow: !0,
                        pointType: null
                    };
                    T[0] && T[1] ? (P.eventType = 3, P.touchIdx = 0) : (P.eventType = 2, T[0] ? P.touchIdx = 0 : P.touchIdx = 1), 
                    this.setData(P, function() {
                        i.triggerEvent("getDrewIdx", {
                            idx: w.idx,
                            len: r.length,
                            path: r[w.idx].path,
                            type: r[w.idx].type,
                            imgType: "local",
                            active: o === w.idx && "text" === r[w.idx].type
                        }), i.draw();
                    });
                } else {
                    var b = {
                        eventType: 1,
                        idx: null,
                        touchData: [],
                        touchIdx: null,
                        isShow: g > 0,
                        pointType: null
                    };
                    b.imgList = 0 === g ? r : w.imgList, this.setData(b, function() {
                        g && i.triggerEvent("getDrewIdx", {
                            idx: null
                        }), i.draw();
                    });
                }
                break;

              case "touchmove":
                if (2 === h) {
                    var M = r[o];
                    if (1 === l) {
                        var E = M.scale, N = M.width * E, O = M.height * E, J = this.data.left + M.x + N / 2, z = this.data.top + M.y + O / 2, k = {
                            x1: J,
                            x2: n[d].x,
                            y1: z,
                            y2: n[d].y
                        }, C = {
                            x1: J,
                            x2: s[d].x,
                            y1: z,
                            y2: s[d].y
                        };
                        M.degree = M.degree + this.getDegree(k, C), r[o] = this.getImgPosition(M), this.setData({
                            imgList: r,
                            touchData: n
                        }, function() {
                            i.draw();
                        });
                    } else if (2 === l) {
                        var R = M.scale, _ = M.width * R, B = M.height * R, q = this.data.left, F = this.data.top, X = q + M.x + _ / 2, A = F + M.y + B / 2, H = M.position[2].x + q, W = M.position[2].y + F, j = M.position[0].x + q, G = M.position[0].y + F, K = n[d].x, Q = n[d].y, U = s[d].x, V = s[d].y, Y = this.getDistance({
                            x1: K,
                            x2: X,
                            y1: Q,
                            y2: A
                        }) / this.getDistance({
                            x1: U,
                            x2: X,
                            y1: V,
                            y2: A
                        });
                        M.scale = R * Y;
                        var Z = !1;
                        (H < X && j >= X && K >= X || W < A && G >= A && Q >= A) && (Z = !0);
                        var $ = !1, tt = M.width >= M.height ? 10 * M.width / M.height : 10, et = M.width >= M.height ? 10 : 10 * M.height / M.width;
                        Y > 1 && this.getDistance({
                            x1: K,
                            x2: X,
                            y1: Q,
                            y2: A
                        }) - Math.sqrt(Math.pow(tt, 2) + Math.pow(et, 2)) <= 0 && ($ = !0), (M.width * M.scale <= 20 || M.height * M.scale <= 20 || Z || $) && (M.scale = M.width >= M.height ? 20 / M.height : 20 / M.width, 
                        Y = M.scale / R), M.x = X - M.width * M.scale / 2 - q, M.y = A - M.height * M.scale / 2 - F, 
                        r[o] = this.getImgPosition(M), this.setData({
                            imgList: r,
                            touchData: n
                        }, function() {
                            i.draw();
                        });
                    } else {
                        var it = n[d].x - s[d].x, at = n[d].y - s[d].y;
                        M.x = M.x + it, M.y = M.y + at, r[o] = this.getImgPosition(M), this.setData({
                            imgList: r,
                            touchData: n
                        }, function() {
                            i.draw();
                        });
                    }
                } else if (3 === h) {
                    var st = r[o], rt = {
                        x1: n[0].x,
                        x2: n[1].x,
                        y1: n[0].y,
                        y2: n[1].y
                    }, nt = {
                        x1: s[0].x,
                        x2: s[1].x,
                        y1: s[0].y,
                        y2: s[1].y
                    }, ht = rt.x1 - nt.x1, ot = rt.x2 - nt.x2, dt = rt.y1 - nt.y1, lt = rt.y2 - nt.y2;
                    if (ht > 0 && ot > 0 || ht < 0 && ot < 0 || dt > 0 && lt > 0 || dt < 0 && lt < 0) break;
                    var gt = st.scale, ct = st.width * gt, ut = st.height * gt, xt = this.getDistance(rt) / this.getDistance(nt), pt = st.scale * xt;
                    if (pt / st.source.scale <= .1) break;
                    st.scale = pt;
                    for (var yt = this.getDegree(rt, nt), ft = st.x + ct / 2, vt = st.y + ut / 2, mt = null, wt = 0; wt < 2; wt++) if (s[wt].x === ft && s[wt].y === vt) {
                        mt = wt;
                        break;
                    }
                    var It = st.x, Dt = st.x;
                    null !== mt ? (It = n[mt].x - st.scale * st.width / 2, Dt = n[mt].y - st.scale * st.height / 2) : (It = ft + (rt.x1 + rt.x2 - (nt.x1 + nt.x2) - st.scale * st.width) / 2, 
                    Dt = vt + (rt.y1 + rt.y2 - (nt.y1 + nt.y2) - st.scale * st.height) / 2), st.x = It, 
                    st.y = Dt, st.degree = st.degree + yt, r[o] = this.getImgPosition(st), this.setData({
                        imgList: r,
                        touchData: n
                    }, function() {
                        i.draw();
                    });
                }
            } else this.setData({
                idx: null,
                isShow: !1,
                touchData: []
            }, function() {
                i.triggerEvent("getDrewIdx", {
                    idx: null
                });
            });
        },
        getSelectedItem: function(e, i) {
            var a = this.data.idx, s = e.length, r = JSON.parse(JSON.stringify(i));
            if (0 === s || s > 2 || 0 === r.length) return r = r.map(function(t) {
                t.selected = !1;
            }), {
                idx: null,
                imgList: r,
                type: null
            };
            if (null !== a) {
                var n = r[a].position;
                if (1 === s) {
                    for (var h = 0; h < n.length; h++) if (this.getIsPointInCircle(n[h], e[0], 15)) return {
                        idx: a,
                        imgList: r,
                        res: {
                            0: !0
                        },
                        type: h
                    };
                    if (this.getIsPointInMatrix(n[0], n[1], n[2], n[3], e[0])) return {
                        idx: a,
                        imgList: r,
                        res: {
                            0: !0
                        },
                        type: null
                    };
                } else {
                    for (var o = 0; o < 2; o++) for (var d = e[o], l = 0; l < n.length; l++) if (this.getIsPointInCircle(n[l], d, 15)) return {
                        idx: a,
                        imgList: r,
                        res: t({}, o, !0),
                        type: l
                    };
                    var g = this.getIsPointInMatrix(n[0], n[1], n[2], n[3], e[0]), c = this.getIsPointInMatrix(n[0], n[1], n[2], n[3], e[1]);
                    if (g || c) return {
                        idx: a,
                        imgList: r,
                        res: {
                            0: g,
                            1: c
                        },
                        type: null
                    };
                }
            }
            var u = null;
            if (1 === s) {
                for (var x = void 0, p = r.length - 1; p >= 0; p--) {
                    var y = r[p].position;
                    r[p].selected = !1, x || (x = this.getIsPointInMatrix(y[0], y[1], y[2], y[3], e[0])) && (r[p].selected = !0, 
                    u = p);
                }
                return {
                    idx: u,
                    imgList: r,
                    type: null
                };
            }
            for (var f = {}, v = null, m = null, w = r.length - 1; w >= 0; w--) {
                var I = r[w].position;
                if (r[w].selected = !1, f[0] || (f[0] = this.getIsPointInMatrix(I[0], I[1], I[2], I[3], e[0]), 
                f[0] && (v = w)), f[1] || (f[1] = this.getIsPointInMatrix(I[0], I[1], I[2], I[3], e[1]), 
                f[1] && (m = w)), f[0] && f[1]) break;
            }
            return null !== v && null !== m ? v >= m ? (r[v].selected = !0, u = v, v > m && (f[1] = !1)) : (r[m].selected = !0, 
            u = m, f[0] = !1) : (null !== v && (r[v].selected = !0, u = v), null !== m && (r[m].selected = !0, 
            u = m)), {
                imgList: r,
                idx: u,
                res: f,
                type: null
            };
        },
        getDistance: function(t) {
            return Math.sqrt(Math.pow(t.x1 - t.x2, 2) + Math.pow(t.y1 - t.y2, 2));
        },
        getDegree: function(t, e) {
            var i = t.x2 - t.x1, a = t.y2 - t.y1, s = e.x2 - e.x1, r = e.y2 - e.y1;
            return this.getDegreeX(i, a) - this.getDegreeX(s, r);
        },
        getDegreeX: function(t, e) {
            return Math.atan2(e, t) * (180 / Math.PI);
        },
        getTriangleLen: function(t, e) {
            var i = 1, a = 1;
            return (e = (e = (e + 360) % 360) > 180 ? e - 360 : e) >= 90 && e < 180 ? i = -1 : e >= -180 && e < -90 ? (i = -1, 
            a = -1) : e >= -90 && e < 0 && (a = -1), e = Math.abs(e), e = e > 90 ? 180 - e : e, 
            e *= Math.PI / 180, {
                x: i * t * Math.cos(e),
                y: a * t * Math.sin(e)
            };
        },
        getImgPosition: function(t) {
            var e = this, i = t.degree, a = t.scale, s = t.width * a, r = t.height * a, n = t.x + s / 2, h = t.y + r / 2, o = s / 2, d = r / 2, l = Math.sqrt(Math.pow(o, 2) + Math.pow(d, 2)), g = [ {
                x: o,
                y: d
            }, {
                x: o,
                y: -d
            }, {
                x: -o,
                y: -d
            }, {
                x: -o,
                y: d
            } ].map(function(t) {
                return e.getDegreeX(t.x, t.y) - i;
            }).map(function(t) {
                return e.getTriangleLen(l, t);
            });
            return g = g.map(function(t) {
                return {
                    x: n + t.x,
                    y: h - t.y
                };
            }), t.position = g, t;
        },
        getIsPointInMatrix: function(t, e, i, a, s) {
            return this.getCross(t, e, s) * this.getCross(i, a, s) >= 0 && this.getCross(e, i, s) * this.getCross(a, t, s) >= 0;
        },
        getCross: function(t, e, i) {
            return (e.x - t.x) * (i.y - t.y - this.data.top) - (i.x - t.x - this.data.left) * (e.y - t.y);
        },
        getIsPointInCircle: function(t, e, i) {
            return Math.sqrt(Math.pow(e.x - (t.x + this.data.left), 2) + Math.pow(e.y - (t.y + this.data.top), 2)) <= i;
        },
        draw: function(t) {
            var e = this, i = this.data.imgList, a = this.ctx, s = null, r = 0, n = this.data.width, h = this.data.height, o = this.data.left, d = this.data.top;
            this.data.isShow && (a.save(), a.setStrokeStyle("#B8B8B8"), a.strokeRect(o - .8, d - .9, n + 2, h + 2), 
            a.restore()), a.save(), a.beginPath(), a.rect(o, d, n, h), a.closePath(), a.clip();
            for (var l = 0; l < i.length; l++) {
                var g = i[l];
                a.save();
                var c = g.scale, u = g.width * c, x = g.height * c, p = o + g.x, y = d + g.y;
                a.translate(p + u / 2, y + x / 2), a.rotate(g.degree * Math.PI / 180), a.translate(-u / 2, -x / 2), 
                g.selected && (s = g, a.save(), a.fillStyle = "rgba(255, 255, 255, 0.5)", a.fillRect(0, 0, u, x), 
                a.restore());
                var f = g.fontSize;
                if ("text" === g.type) {
                    a.fillStyle = g.color, a.setTextAlign("center"), a.save();
                    var v = f;
                    if (a.setFontSize(v * c), v < 80 && a.measureText(g.path).width < u - 10 * c) for (;a.measureText(g.path).width < u - 10 * c && v < 80; ) a.restore(), 
                    v += 1, a.setFontSize(v * c), a.save();
                    for (;a.measureText(g.path).width > u - 10 * c; ) a.restore(), v -= 1, a.setFontSize(v * c), 
                    a.save();
                    a.font = (g.isBold ? "normal bold " : "") + "10px sans-serif", a.setFontSize(v * c), 
                    g.fontSize = v, a.setTextBaseline("middle"), a.fillText(g.path, u / 2, x / 2, u - 10 * c), 
                    a.restore();
                } else a.drawImage(g.path, 0, 0, u, x);
                a.restore(), "function" == typeof t && "text" === g.type && f !== g.fontSize && (r++, 
                i[l] = g);
            }
            if (s) {
                a.restore(), a.save();
                var m = s.scale, w = s.width * m, I = s.height * m, D = o + s.x, L = d + s.y;
                a.translate(D + w / 2, L + I / 2), a.rotate(s.degree * Math.PI / 180), a.translate(-w / 2, -I / 2), 
                a.setStrokeStyle("blue"), a.strokeRect(0, 0, w, I), a.drawImage("../../assets/images/icon_zz_8.png", -15, -15, 30, 30), 
                a.drawImage("../../assets/images/icon_zz_10.png", w - 15, -15, 30, 30), a.drawImage("../../assets/images/icon_zz_7.png", -15, I - 15, 30, 30), 
                a.drawImage("../../assets/images/icon_zz_9.png", w - 15, I - 15, 30, 30), a.rect(o, d, n, h);
            }
            a.draw(!1, function() {
                "function" == typeof t && t(), r > 0 && e.setData({
                    imgList: i
                });
            });
        },
        getCoverimg: function(t) {
            var e = this, i = this.data.imgList;
            i.length < 1 || this.draw(function() {
                var a = e.data.width, s = e.data.height, r = [], n = [];
                i.forEach(function(t) {
                    t.position.forEach(function(t) {
                        r.push(t.x), n.push(t.y);
                    });
                }), r = r.sort(function(t, e) {
                    return t - e;
                }), n = n.sort(function(t, e) {
                    return t - e;
                });
                var h = r[0], o = r[r.length - 1], d = n[0], l = n[n.length - 1];
                h < 0 && (h = 0), o > a && (o = a), d < 0 && (d = 0), l > s && (l = s);
                var g = o - h, c = l - d;
                g < 1 && (g = a), c < 1 && (c = s);
                var u = 500 / g, x = 500 / c, p = Math.ceil(u > x ? u : x);
                wx.canvasToTempFilePath({
                    canvasId: e.data._id,
                    x: e.data.left + h,
                    y: e.data.top + d,
                    width: g,
                    height: c,
                    destWidth: g * p,
                    destHeight: c * p,
                    fileType: "png",
                    success: function(e) {
                        "function" == typeof t && t(e.tempFilePath);
                    },
                    fail: function(t) {
                        wx.hideLoading(), wx.showModal({
                            title: "生成原图失败",
                            content: JSON.stringify(t)
                        });
                    }
                }, e);
            }, "copy");
        }
    }
});